$(document).ready(function () {


	//-----------------------------------------定义和初始化变量----------------------------------------
	var loadBox = $('aside.loadBox');
	var articleBox = $('article');
	var windowScale = window.innerWidth / 750;



	init_share();


	//----------------------------------------有微信授权放这里  授权完在 icom.init(init)----------------------------------------
	var openId, nickName, headUrl;
	// 没有授权
	if (!window.localStorage.getItem("token")) {
		login_fn();
	} else {

		userOpenId(init_localStore(2, "openId"));
		icom.init(init);//初始化
	}

	function login_fn() {
		openId = icom.getQueryString("openId");
		nickName = icom.getQueryString("nickName");
		headUrl = icom.getQueryString("headimgUrl");
		if (openId || nickName || headUrl) {
			// console.log('openId:::::: ', openId);
			// console.log('nickName:::::: ', nickName);
			// console.log('headUrl:::::: ', headUrl);
			init_localStore(1, "openId", openId)
			init_localStore(1, "nickName", decodeURIComponent(nickName).replace(/\+/g, " "))
			init_localStore(1, "headUrl", headUrl)
			API.userRegister({
				openId,
				nickName: decodeURIComponent(nickName).replace(/\+/g, " "),
				headUrl,
			}, (res) => {
				if (res.code == 200) {
					// window.localStorage.setItem("token", res.msg);
					init_localStore(1, "token", res.msg);
					userOpenId(openId);
					icom.init(init);//初始化
				}
			})


		} else {
			console.log("2cec50cf83ae4210a17ebdd26c0e57de")	// 雷达
			console.log("3009d0a1e2b04ea9a43f22427729d050") //百盛
			let auth_url = "https://rado-h5.omnimkt.com/html/rado/tanabata/index.html";
			window.location.replace(
				"https://open.omnimkt.com/api/to_qrConnectUrl/2cec50cf83ae4210a17ebdd26c0e57de?redirectUri=" + auth_url + "&scope=true"
			)
		}
	}

	// 特殊用户
	function userOpenId(openId) {
		if (openId == "oyMUmt-xZ42vbVXKaCkOkzeKCkmY") {
			API.userOpenId({ openId }, (res) => {
				if (res.code == 200) {
					init_localStore(1, "nickName", decodeURIComponent(res.data[0].nickname).replace(/\+/g, " "))
				}
			})
		}
	}

	//----------------------------------------重置分享----------------------------------------

	function init_share(article = "Rado x白宇浪漫甄选，FEEL IT FEEL LOVE") {
		var share = {};
		share.title = 'Rado By U七夕限定款预购盛启';
		share.friend = share.timeline = share.other = article;
		ishare.reset(share);
	}

	icom.screenScrollUnable();//如果是一屏高度项目且在ios下，阻止屏幕默认滑动行为

	function init() {
		requestAnimationFrame(function () {
			var screenProp = window.innerWidth / window.innerHeight
			console.log('window.innerWidth: ', window.innerWidth);
			console.log('window.innerHeight: ', window.innerHeight);
			// alert(window.innerWidth)
			// alert(window.innerHeight)
			console.log("os.screenProp:" + screenProp);
			if (screenProp < 0.54) articleBox.addClass("screen189");
			if (screenProp > 0.61) articleBox.addClass("screen159");
			load_handler();
			init_vue();
		});
	}//edn func


	//----------------------------------------加载页面图片----------------------------------------
	function load_handler() {
		var loader = new PxLoader();
		var obj = "https://cdn.omnimkt.com/2021_07/rado/";
		var math = 3;
		loader.addImage(obj + 'images/common/turn_phone.png?v=' + math);
		loader.addImage(obj + 'images/p1/bg.jpg?v=' + math);
		loader.addImage(obj + 'images/p1/bg2.png?v=' + math);
		loader.addImage(obj + 'images/p1/box.png?v=' + math);
		loader.addImage(obj + 'images/p1/box2.png?v=' + math);
		loader.addImage(obj + 'images/p1/down.png?v=' + math);
		loader.addImage(obj + 'images/p1/logo.png?v=' + math);
		loader.addImage(obj + 'images/p1/rules.png?v=' + math);
		loader.addImage(obj + 'images/p1/tip.png?v=' + math);
		loader.addImage(obj + 'images/p1/tip2.png?v=' + math);
		loader.addImage(obj + 'images/p1/rules/bg.png?v=' + math);
		loader.addImage(obj + 'images/p1/rules/close.png?v=' + math);
		loader.addImage(obj + 'images/p1/rules/content.png?v=' + math);
		loader.addImage(obj + 'images/p1/rules/title.png?v=' + math);
		loader.addImage(obj + 'images/p1/home2/b1.png?v=' + math);
		loader.addImage(obj + 'images/p1/home2/b2.png?v=' + math);
		loader.addImage(obj + 'images/p1/home2/box.png?v=' + math);
		loader.addImage(obj + 'images/p1/home2/i1.png?v=' + math);
		loader.addImage(obj + 'images/p1/home2/input.png?v=' + math);
		loader.addImage(obj + 'images/p1/home2/pic.png?v=' + math);
		loader.addImage(obj + 'images/p1/home2/send.png?v=' + math);
		loader.addImage(obj + 'images/p1/home2/share.png?v=' + math);
		loader.addImage(obj + 'images/p1/home2/top.png?v=' + math);
		loader.addImage(obj + 'images/p1/home2/watch.png?v=' + math);
		loader.addImage(obj + 'images/p2/bg.jpg?v=' + math);
		loader.addImage(obj + 'images/p2/go.png?v=' + math);
		loader.addImage(obj + 'images/p2/gif/1.jpg?v=' + math);
		loader.addImage(obj + 'images/p2/gif/2.gif?v=' + math);
		loader.addImage(obj + 'images/p2/gif/3.jpg?v=' + math);
		loader.addImage(obj + 'images/p2/gif/4.gif?v=' + math);
		loader.addImage(obj + 'images/p2/gif/5.gif?v=' + math);
		loader.addImage(obj + 'images/p2/gif/6.gif?v=' + math);
		loader.addImage(obj + 'images/p2/gif/7.gif?v=' + math);
		loader.addImage(obj + 'images/p2/gif/8.jpg?v=' + math);
		loader.addImage(obj + 'images/p3/bao.png?v=' + math);
		loader.addImage(obj + 'images/p3/bg.jpg?v=' + math);
		loader.addImage(obj + 'images/p3/box.png?v=' + math);
		loader.addImage(obj + 'images/p3/cloud.png?v=' + math);
		loader.addImage(obj + 'images/p3/code_text.png?v=' + math);
		loader.addImage(obj + 'images/p3/i1.png?v=' + math);
		loader.addImage(obj + 'images/p3/i2.png?v=' + math);
		loader.addImage(obj + 'images/p3/i3.png?v=' + math);
		loader.addImage(obj + 'images/p3/info.png?v=' + math);
		loader.addImage(obj + 'images/p3/t1.png?v=' + math);
		loader.addImage(obj + 'images/p3/t2.png?v=' + math);
		loader.addImage(obj + 'images/p3/tip1.png?v=' + math);
		loader.addImage(obj + 'images/p3/tip2.png?v=' + math);
		loader.addImage(obj + 'images/p3/tip3.png?v=' + math);
		loader.addImage(obj + 'images/p3/watch.png?v=' + math);
		loader.addImage(obj + 'images/p3/mask/b1.png?v=' + math);
		loader.addImage(obj + 'images/p3/mask/b2.png?v=' + math);
		loader.addImage(obj + 'images/p3/mask/bg.png?v=' + math);
		loader.addImage(obj + 'images/p3/mask/close.png?v=' + math);
		loader.addImage(obj + 'images/p3/mask/tip1.png?v=' + math);
		loader.addImage(obj + 'images/p3/mask/empty/b1.png?v=' + math);
		loader.addImage(obj + 'images/p3/mask/empty/bg.png?v=' + math);
		loader.addImage(obj + 'images/p3/mask/empty/tip1.png?v=' + math);
		loader.addImage(obj + 'images/p3/mask/success/bg.png?v=' + math);
		loader.addImage(obj + 'images/p3/mask/success/i1.png?v=' + math);
		loader.addImage(obj + 'images/p3/mask/success/t1.png?v=' + math);
		loader.addImage(obj + 'images/p3/mask/success/tip1.png?v=' + math);
		loader.addImage(obj + 'images/p3/mask/success/tip2.png?v=' + math);
		loader.addImage(obj + 'images/p4/a1.png?v=' + math);
		loader.addImage(obj + 'images/p4/a2.png?v=' + math);
		loader.addImage(obj + 'images/p4/bg.jpg?v=' + math);
		loader.addImage(obj + 'images/p4/cloud.png?v=' + math);
		loader.addImage(obj + 'images/p4/i1.png?v=' + math);
		loader.addImage(obj + 'images/p4/i2.png?v=' + math);
		loader.addImage(obj + 'images/p4/i3.png?v=' + math);
		loader.addImage(obj + 'images/p4/p1.png?v=' + math);
		loader.addImage(obj + 'images/p4/p2.png?v=' + math);
		loader.addImage(obj + 'images/p4/submit.png?v=' + math);
		loader.addImage(obj + 'images/p4/t1.png?v=' + math);
		loader.addImage(obj + 'images/p4/t2.png?v=' + math);
		loader.addImage(obj + 'images/p4/t3.png?v=' + math);
		loader.addImage(obj + 'images/p4/yuyue.png?v=' + math);
		loader.addImage(obj + 'images/p4/mask/bg.png?v=' + math);
		loader.addImage(obj + 'images/p4/mask/submit.png?v=' + math);
		loader.addImage(obj + 'images/p4/mask/title1.png?v=' + math);
		loader.addImage(obj + 'images/p4/mask/title2.png?v=' + math);
		loader.addImage(obj + 'images/p5/b1.png?v=' + math);
		loader.addImage(obj + 'images/p5/b2.png?v=' + math);
		loader.addImage(obj + 'images/p5/b3.png?v=' + math);
		loader.addImage(obj + 'images/p5/bg.jpg');
		loader.addImage(obj + 'images/p5/code.png?v=' + math);
		loader.addImage(obj + 'images/p5/logo.png?v=' + math);
		loader.addImage(obj + 'images/p5/pic.png?v=' + math);
		loader.addImage(obj + 'images/p5/t1.png?v=' + math);
		loader.addImage(obj + 'images/p5/t2.png?v=' + math);
		loader.addImage(obj + 'images/p5/t3.png?v=' + math);
		loader.addImage(obj + 'images/p5/tip1.png?v=' + math);
		loader.addImage(obj + 'images/p5/tip2.png?v=' + math);
		loader.addImage(obj + 'images/p5/tip3.png?v=' + math);
		loader.addImage(obj + 'images/p5/mask/b1.png?v=' + math);
		loader.addImage(obj + 'images/p5/mask/bg.png?v=' + math);
		loader.addImage(obj + 'images/p5/mask/tip.png?v=' + math);

		//实际加载进度
		//		loader.addProgressListener(function(e) {
		//			var per=Math.round(e.completedCount/e.totalCount*50);
		//			loadPer.html(per+'%');
		//		});

		loader.addCompletionListener(function () {
			loadBox.hide();
			// icom.fadeIn(articleBox);
			pageInit();
			//			load_timer(50);//模拟加载进度
			loader = null;
		});
		loader.start();
	}//end func

	//模拟加载进度
	function load_timer(per) {
		per = per || 0;
		per += imath.randomRange(1, 3);
		per = per > 100 ? 100 : per;
		loadPer.html(per + '%');
		if (per == 100) setTimeout(pageInit, 200);
		else setTimeout(load_timer, 33, per);
	}//edn func

	//----------------------------------------页面逻辑代码----------------------------------------



	/**
	 * 页面初始化
	 */
	function pageInit() {


		// init_vue();
		monitor_handler();


		// icom.countdown($('.btnCode'), 60, '#s');
	}//end func


	// 逻辑代码


	let p1_swiper, p1_rules_swiper, p2_swiper, p4_swiper;
	let code_time = null, damu_time = null, init_damu_time = null;
	// 初始化缓存
	function init_localStore(obj, key, value) {
		if (obj == 1) {
			window.localStorage.setItem(key, value)
		} else {
			return window.localStorage.getItem(key);
		}
	}


	function init_vue() {
		new Vue({
			el: "#app",
			data: {
				subscribe_status: "",
				rules_flag: false,//活动规则弹窗
				danmu_flag: true,//弹幕状态 发完之后隐藏
				share_flag: false,//分享提示
				p_state: 1,
				headUrl: "",//授权头像
				nickName: "",//授权名称
				go_flag: false,//产品展示页的按钮 一开始不显示 滑动显示
				p2_mask: false,//p2弹窗
				p3_mask: false,//p3弹窗
				p4_mask: false,//p4弹窗
				code_text: 30,
				code_flag: true,//验证码状态
				userInfoRegister: {
					name: "",//姓名
					mobile: "",//手机号码
					code: "",//验证码
					province: "",//
					city: "",
					channel: 0,//渠道
				},
				mask_state: 0,
				get_share_state: null,//0线下  1天猫   2 京东
				imgList: [],
				canvas_img: "",
				imginfo: {
					width: "",
					height: ""
				},
				confession_number: 520,//人数
				showList: [],//店铺列表
				bindingAddress: {
					shopId: "",
					mobile: "",
					province: "",
					city: "",
					channel: 0,
				},//用户绑定店铺
				addressAcitveIndex: -1,//动图默认选中的索引
				channel: "",//渠道
				cat_flag: false,//天猫
				dog_flag: false,//京东
				is_user: false,//判断该用户有咩有预约过任何信息
				jd_url: "https://item.m.jd.com/product/100012905249.html",
			},
			mounted() {
				this.init_p1_swiper();
				this.init_p1_rules_swiper();
				this.init_p2_swiper();


			},
			created() {
				this.nickName = init_localStore(2, "nickName");
				this.subscribeTimTm();
				this.subscribeTimJd();
				this.subscribeStatus();
				this.getUserInfoFn();
				// $(".p1").hide();
				// $(".p5").show();

				// this.init_img();
			},
			filters: {
				KMFilter: (value) => {
					return value.toFixed(2);
				}
			},
			methods: {

				// 用户信息回显  -- 废弃
				getUserInfoFn() {
					if (init_localStore(2, "userInfoRegister")) {
						this.userInfoRegister = JSON.parse(init_localStore(2, "userInfoRegister"));
						this.userInfoRegister.code = "";

						// API.subscribeInfoMobile({ mobile: this.userInfoRegister.mobile }, (res) => {
						// 	if (res.code == 200) {
						// 		// if(res.data.length == 0){
						// 		// 	this.is_user = false;
						// 		// }else{
						// 		// 	this.userInfoRegister = res.data[0];
						// 		// 	this.is_user = true;
						// 		// }
						// 	}

						// })
					}
					// API.getUserInfo({}, (res) => {
					// 	if (res.code == 200) {
					// 		// this.isPush = res.data.isPush;
					// 		this.userInfoRegister = Object.assign(this.userInfoRegister, res.data);
					// 	}
					// })
				},

				// 预约时间比较 天猫
				subscribeTimTm() {
					API.subscribeTimTm({}, (res) => {
						if (res.code == 200) {
							this.cat_flag = res.data;
						}
					})

				},

				// 预约时间比较 京东
				subscribeTimJd() {
					API.subscribeTimJd({}, (res) => {
						if (res.code == 200) {
							this.dog_flag = res.data;
						}
					})
				},

				// 预约状态
				subscribeStatus() {
					API.subscribeStatus({}, (res) => {
						if (res.code == 200) {
							this.subscribe_status = res.data;
						}
					})
				},

				// 下一页
				home1_btn() {
					p1_swiper.slideNext();
				},

				// 打开活动规则
				open_rules_btn() {
					$(".rules_mask").show();
					p1_rules_swiper.update();
				},

				// 活动规则
				rules_btn() {
					$(".rules_mask").hide();
				},

				// 弹幕
				init_danmu(barrageContentList, length) {
					var option = {
						container: "#danmu",//弹幕墙的id
						barrageLen: 5//弹幕的行数
					}
					barrageWall.init(option);//初始化弹幕墙

					var num = 0, timer = setInterval(() => {
						if (num >= length) {
							clearInterval(timer);
							num = 0;
							this.init_danmu(barrageContentList, barrageContentList.length);
						} else {
							barrageWall.upWall(barrageContentList[num].barrageContent);
						}
						num++;
					}, 1000);
				},

				// 发送弹幕
				send_danmu_btn() {
					let danmu_text = $(".home2 .input_info").val();
					if (danmu_text === "")
						return icom.alert("请输入你的告白");
					barrageWall.upWall(danmu_text, { color: '#c69f7c', size: '.33', zIndex: 2 });
					// 弹幕审核接口
					API.userSendBarrage({ content: danmu_text }, (res) => {
						if (res.code == 200) {


						}
					})

					this.confessionTimes(() => {
						// 将分享的人数存到本地
						let share_num = init_localStore(2, "share_num");
						if (share_num) {

						} else {
							init_localStore(1, "share_num", this.confession_number);
						}
						init_share("我是第" + init_localStore(2, "share_num") + "位成功“宇”你告白的人，FEEL LOVE BY U");
					});

					this.danmu_flag = false;
					damu_time = setInterval(() => {
						barrageWall.upWall(danmu_text, { color: '#c69f7c', size: '.33', zIndex: 2 });
					}, 4200)
				},
				// 弹幕列表
				userBarrageListFn() {
					API.userBarrageList({ pageSize: 100 }, (res) => {
						if (res.code == 200) {
							let barrageContentList = res.rows;
							this.init_danmu(barrageContentList, barrageContentList.length);

						}
					})
				},

				// 用户表白人数
				confessionTimes(fn) {
					API.confessionTimes({}, (res) => {
						if (res.code == 200) {
							this.confession_number = res.data;
							fn && fn()
						}
					})
				},


				// 分享
				share_btn() {
					// this.share_flag = true;
					$(".share_box").show();
				},

				// 第2页
				next_p1_btn() {
					this.hide_show_page(".p1", ".p2");
					clearInterval(damu_time);
					p2_swiper.update();
					init_share("Rado x白宇浪漫甄选，FEEL IT FEEL LOVE");
				},

				// 关闭分享
				close_share_btn() {
					// this.share_flag = false;
					$(".share_box").hide();
				},

				// 去预约
				go_subscribe_btn() {
					if (parseInt(this.subscribe_status) == 0) {
						this.p2_mask = true;
						this.mask_state = 5;
					} else {
						this.hide_show_page(".p2", ".p3");
						// if (true) {
						// 	this.p3_mask = true;
						// 	this.mask_state = 5;
						// }
					}

				},

				// 获取验证码
				get_code_btn() {
					if (!icom.checkStr(this.userInfoRegister.mobile))
						return icom.alert("请输入正确的手机号码!");
					if (this.code_flag) {
						API.smsSend(this.userInfoRegister, (res) => {
							if (res.code === 200) {
								this.code_flag = false;
								code_time = setInterval(() => {
									this.code_text--;
									if (this.code_text < 0) {
										this.code_text = 30;
										clearInterval(code_time);
										this.code_flag = true;
									}
								}, 1000)

								if ("user" in res.data) {
									delete res.data.user.name //true
									this.userInfoRegister = Object.assign(this.userInfoRegister, res.data.user)
									this.is_user = true;
								} else {
									this.userInfoRegister.code = "";
									this.userInfoRegister.province = "";
									this.userInfoRegister.city = "";
									this.userInfoRegister.channel = "";
								}
								this.bindingAddress.mobile = this.userInfoRegister.mobile;
							}
						})

					}
				},

				// 省份
				province_btn(e) {
					var that = this;
					let depth = 2;
					weui.picker(cityData, {
						depth: depth,
						className: 'picker',
						container: 'article',
						defaultValue: [this.bindingAddress.province.replace("市", ""), this.bindingAddress.city, ""],
						onChange: function (result) {
							// console.log(result);
						},
						onConfirm: function (result) {
							// console.log('result: ', result);
							var html = "";
							for (var i = 0; i < depth; i++) {
								// console.log(result[i]);
								if (i < depth - 1) {
									html += result[i].label + "-";
									that.userInfoRegister.province = result[i].label;
									if (e == 2) {
										that.bindingAddress.province = result[i].label;
									}
								} else {
									html += result[i].label;
									that.userInfoRegister.city = result[i].label;
									if (e == 2) {
										that.bindingAddress.city = result[i].label;
										that.select_city(that.userInfoRegister.city.replace("市", ""));
									}
								}
							}//edn for
						},
						id: 'cityPicker'
					});
				},


				select_city(city) {
					API.listCity({ city }, (res) => {
						if (res.code == 200) {
							this.showList = [];
							this.showList = res.data;
							this.$nextTick(() => {
								// p4_swiper.update();
								this.init_p4_swiper();
							})
							loadBox.hide();
						}
					})
				},

				// 专柜预约
				offline_sub_btn() {
					let { name, mobile, code, channel } = this.userInfoRegister;
					if (name == "")
						return icom.alert("姓名不能为空!");
					else if (!icom.checkStr(mobile))
						return icom.alert("手机号码格式不对!");
					else if (code == "")
						return icom.alert("验证码不能为空!");
					API.subscribeInfoMobile({ mobile: this.userInfoRegister.mobile }, (res) => {
						if (res.code == 200) {
							if (res.data.length == 0) {
								this.userInfoRegister.channel = 0;
								this.userInfoRegisterFn((res) => {
									this.hide_show_page(".p3", ".p4");
									this.getCurrentGPS();
									// this.init_p4_swiper();
								})

							} else {
								// this.userInfoRegister = Object.assign(this.userInfoRegister, res.data[0]);
								this.bindingAddress.mobile = res.data[0].mobile;
								this.userInfoRegister.channel = res.data[0].channel;
								this.userInfoRegister.mobile = res.data[0].mobile;
								this.userInfoRegister.shopName = res.data[0].shopName;
								// this.userInfoRegister.name = res.data[0].name;
								this.p3_mask = true;
								this.is_channel(this.userInfoRegister.channel);
							}
						}
					})
					this.channel = 0;
					init_localStore(1, "userInfoRegister", JSON.stringify(this.userInfoRegister));
					// this.userInfoRegisterFn((res) => {
					// 	let { name, channel } = this.userInfoRegister;
					// 	// 已经预约过了
					// 	if (name) {
					// 		this.p3_mask = true;
					// 		this.is_channel(channel);
					// 	} else {
					// 		this.hide_show_page(".p3", ".p4");
					// 	}
					// });
				},

				// 线上预约
				online_sub_btn(e) {
					let { name, mobile, code, channel } = this.userInfoRegister;
					if (name == "")
						return icom.alert("姓名不能为空!");
					else if (!icom.checkStr(mobile))
						return icom.alert("手机号码格式不对!");
					else if (code == "")
						return icom.alert("验证码不能为空!");
					API.subscribeInfoMobile({ mobile: this.userInfoRegister.mobile }, (res) => {
						if (res.code == 200) {
							this.p3_mask = true;
							if (res.data.length == 0) {
								this.mask_state = 4;
								this.userInfoRegister.channel = e;
								this.userInfoRegisterFn((res) => {

								})
							} else {
								// this.userInfoRegister = Object.assign(this.userInfoRegister, res.data[0]);
								this.userInfoRegister.channel = res.data[0].channel;
								this.userInfoRegister.mobile = res.data[0].mobile;
								this.userInfoRegister.shopName = res.data[0].shopName;
								this.is_channel(this.userInfoRegister.channel);
								this.bindingAddress.mobile = res.data[0].mobile;
							}
						}
					})
					init_localStore(1, "userInfoRegister", JSON.stringify(this.userInfoRegister));
					this.get_share_state = e;
					this.channel = e;
					// this.userInfoRegisterFn((res) => {
					// 	let { name, channel } = this.userInfoRegister;
					// 	this.p3_mask = true;
					// 	if (name) {
					// 		this.is_channel(channel);
					// 	} else {
					// 		this.mask_state = 4;
					// 	}
					// 	this.get_share_state = e || 0;
					// 	console.log('this.get_share_state p3: ', this.get_share_state);
					// 	this.channel = e;
					// 	// this.userInfoRegister.channel = e;

					// 	// if (userInfoRegisterFn) {
					// 	// 	if (e == 1) {
					// 	// 		this.mask_state = 2;
					// 	// 	} else if (e == 2) {
					// 	// 		this.mask_state = 3;
					// 	// 	}
					// 	// } else {

					// 	// }
					// })
				},

				// 判断用户已经预约了哪一个
				is_channel(channel) {
					if (parseInt(channel) === 0) {
						// 线下
						this.mask_state = 1;
					} else if (parseInt(channel) == 1) {
						this.mask_state = 2;
						// 天猫
					} else if (parseInt(channel) == 2) {
						// 京东
						this.mask_state = 3;
					}
				},

				// 用户登记
				userInfoRegisterFn(fn) {
					let { name, mobile, code } = this.userInfoRegister;
					if (name == "")
						return icom.alert("姓名不能为空!");
					else if (!icom.checkStr(mobile))
						return icom.alert("手机号码格式不对!");
					else if (code == "")
						return icom.alert("验证码不能为空!");
					API.userInfoRegister(this.userInfoRegister, (res) => {
						if (res.code == 200) {
							fn(res);
						}
					})
				},

				// 更新预约
				update_sub_btn(e) {
					console.log(this.channel)
					switch (parseInt(this.channel)) {
						case 0:
							this.userInfoRegisterFn((res) => {
								this.hide_show_page(".p3", ".p4");
								this.getCurrentGPS();
							})


							// this.init_p4_swiper();
							break;
						case 1:
							this.userInfoRegister.channel = this.channel;
							this.userInfoRegisterFn((res) => {
								this.mask_state = 4;
								// this.get_share_state = e || 0;
							})
							break;
						case 2:
							this.userInfoRegister.channel = this.channel;
							this.userInfoRegisterFn((res) => {
								this.mask_state = 4;
								// this.get_share_state = e || 0;
							})
							break;
					}
					// if (e == 0) {
					// 	this.hide_show_page(".p3", ".p4");
					// 	p4_swiper.update();
					// } else {
					// 	this.userInfoRegister.channel = e;
					// 	this.userInfoRegisterFn((res) => {
					// 		this.mask_state = 4;
					// 		this.get_share_state = e || 0;
					// 	})

					// }
				},

				// 保留预约
				attention_btn() {
					this.mask_state = 8;
				},

				online_p4_sub_btn(e) {
					this.userInfoRegister.channel = e;
					this.userInfoRegisterFn((res) => {
						this.p4_mask = true;
						this.mask_state = 4;
						this.get_share_state = e || 0;
						this.channel = e;
					})
				},

				// 确认提交
				submit_btn() {
					let { shopId } = this.bindingAddress;
					if (shopId == "")
						return icom.alert("请选择店铺!");
					API.bindingAddress(this.bindingAddress, (res) => {
						if (res.code == 200) {
							this.mask_state = 6;
						}

					})

				},

				submit_canvas_btn() {
					this.hide_show_page(".p4", ".p5");
					this.get_share_state = 0;
					this.init_img();
				},


				// 确认生产专属预约凭证
				canvas_page_btn() {
					this.hide_show_page(".p3", ".p5");
					this.init_img();
					console.log('this.get_share_state: ', this.get_share_state);
					if (this.get_share_state == 1) {
						imonitor.add({ category: 'default', label: '天猫预约 预约成功 确认生成专属预约凭证' });
					} else if (this.get_share_state == 2) {
						imonitor.add({ category: 'default', label: '京东预约 预约成功 确认生成专属预约凭证' });
					}
				},
				canvas_p4_page_btn() {
					this.hide_show_page(".p4", ".p5");
					this.init_img();
					if (this.get_share_state == 1) {
						imonitor.add({ category: 'default', label: '天猫预约 预约成功 确认生成专属预约凭证' });
					} else if (this.get_share_state == 2) {
						imonitor.add({ category: 'default', label: '京东预约 预约成功 确认生成专属预约凭证' });
					}
				},

				// 初始化地图
				initMap(lat, lng) {
					var map = new BMap.Map("allmap");
					// 创建地图实例  
					var point = new BMap.Point(lng, lat);
					// 创建点坐标  
					map.centerAndZoom(point, 15);
					// 初始化地图，设置中心点坐标和地图级别  
					map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
					// var marker = new BMap.Marker(point);        // 创建标注    
					// map.addOverlay(marker);                     // 将标注添加到地图中 
					// 自定义---标注
					// var myIcon = new BMap.Icon("https://arcteryxstore.beats-digital.com/images/p2/location.png", new BMap.Size(50, 50));	//替换标注图片和图片大小
					// var marker2 = new BMap.Marker(point, { icon: myIcon });  // 创建标注
					// map.addOverlay(marker2);              // 将标注添加到地图中
					// 自定义---标注
					//坐标转换完之后的回调函数
					translateCallback = function (data) {
						if (data.status === 0) {
							var myIcon = new BMap.Icon("./images/p4/a1.png", new BMap.Size(28, 38));	//替换标注图片和图片大小
							var marker = new BMap.Marker(data.points[0], { icon: myIcon });
							map.addOverlay(marker);
							var label = new BMap.Label("", { offset: new BMap.Size(20, -10) });
							marker.setLabel(label); //添加百度label
							map.setCenter(data.points[0]);
						}
					}

					setTimeout(function () {
						var convertor = new BMap.Convertor();
						var pointArr = [];
						pointArr.push(point);
						convertor.translate(pointArr, COORDINATES_WGS84, COORDINATES_BD09, translateCallback)
					}, 200);

				},

				// 获取地理位置接口
				getCurrentGPS() {
					loadBox.show();
					var that = this;
					var map = new BMap.Map("allmap");
					// 定位
					var geolocation = new BMap.Geolocation({
						maximumAge: 10  // 清除缓存
					});
					geolocation.getCurrentPosition(function (r) {
						if (this.getStatus() == BMAP_STATUS_SUCCESS) {
							var mk = new BMap.Marker(r.point);
							map.addOverlay(mk);
							map.panTo(r.point);
							console.log('您的位置：' + r.point.lng + ',' + r.point.lat);
							lat = r.point.lat;
							lng = r.point.lng;
							// var url = "https://api.map.baidu.com/geocoder?location=" + r.point.lat + "," + r.point.lng + "&output=json&key=" + addressKey;
							// latlngtocode(lat, lng);
							that.initMap(lat, lng);

							that.getLocation(lat, lng);
						}
						else {
							alert('failed' + this.getStatus());
						}
					});

				},

				// 获取城市名
				getLocation(lat, lng) {
					var that = this;
					// 创建地理编码实例      
					var myGeo = new BMapGL.Geocoder();
					// 根据坐标得到地址描述    
					myGeo.getLocation(new BMapGL.Point(lng, lat), (result) => {
						if (result) {
							// console.log(result);
							let { province, city } = result.addressComponents;
							that.bindingAddress.province = province.replace("市", "");
							that.bindingAddress.city = city;
							that.select_city(city.replace("市", ""));
							// that.shopList(lat, lng);

						}
					});
				},


				// 店铺列表
				shopList(latitude, longitude) {
					API.shopList({ latitude, longitude }, (res) => {
						if (res.code == 200) {
							this.showList = [];
							this.showList = res.data;
							this.$nextTick(() => {
								// p4_swiper.update();
								this.init_p4_swiper();

							})

						}
					})
				},

				// 跳转地图
				jump_address(lat, lng, shopName, shopAddress, shopId, index) {
					// console.log('shopAddress: ', shopAddress);
					// console.log('shopName: ', shopName);
					// console.log('lng: ', lng);
					// console.log('lat: ', lat);
					this.bindingAddress.shopId = shopId;
					this.addressAcitveIndex = index;
					// wx.openLocation({
					// 	latitude: lat, // 纬度，浮点数，范围为90 ~ -90
					// 	longitude: lng, // 经度，浮点数，范围为180 ~ -180。
					// 	name: shopName, // 位置名
					// 	address: shopAddress, // 地址详情说明
					// 	scale: 17, // 地图缩放级别,整形值,范围从1~28。默认为最大
					// 	infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
					// });

					this.initMap(lat, lng);
				},

				// 自动适配大图
				media_big_img() {
					let wd = $("#canvas_box").width();
					let ht = $("#canvas_box").height();
					let imgWd = $(".canvas_big_img").width();
					let imgHt = $(".canvas_big_img").height();
					var size = imath.autoSize([wd, ht], [wd, ht], 1);
					this.imginfo.width = size[0] + "px";
					this.imginfo.height = size[1] + "px";
				},

				init_img() {
					loadBox.show();
					imgList = [];
					for (let i = 0; i < 600; i++) {
						var obj = {};
						obj.id = i;
						obj.img = init_localStore(2, "headUrl");
						this.imgList.push(obj);
					}
					setTimeout(() => {
						this.html2Canvas();
					}, 2000)
				},

				// 合成图片
				html2Canvas() {
					html2canvas(document.querySelector("#canvas_box"), {
						logging: false,
						useCORS: true,
						dpi: window.devicePixelRatio * 2,
						scale: 4,
						backgroundColor: null,
					}).then(canvas => {
						// var url = canvas.toDataURL();//图片地址
						var base64 = canvas.toDataURL("image/png", 1);  //将canvas转成图片
						this.canvas_img = base64;
						this.media_big_img();
						loadBox.hide();
					});
				},

				// 显示天猫弹窗
				tmail_btn() {
					this.mask_state = 7;
					const textCopied = ClipboardJS.copy('5￥tndDX9nmbsF￥ https://m.tb.cn/h.4zaW6pu');
				},

				// 隐藏弹窗
				hide_mask() {
					this.mask_state = 0;
					this.p2_mask = false;
					this.p3_mask = false;
					this.p4_mask = false;
				},

				// 显示页面
				hide_show_page(obj1, obj2) {
					$(obj1).hide();
					$(obj2).show();
				},

				// 初始化首页滚动swiper
				init_p1_swiper() {
					let that = this;
					p1_swiper = new Swiper('.p1_info.swiper-container', {
						direction: 'vertical',
						resistanceRatio: 0,
						on: {
							slideChange: function () {
								var index = this.realIndex;
								if (index === 1) {
									// that.init_danmu();
									that.userBarrageListFn();
									that.confessionTimes();
									that.headUrl = init_localStore(2, "headUrl");
								}
							}
						}
					});
				},

				// 京东连接跳转
				link_jd_btn() {
					window.location.replace(this.jd_url);
				},


				init_p1_rules_swiper() {
					p1_rules_swiper = new Swiper('.rules_box .swiper-container', {
						direction: 'vertical',
						roundLengths: true,
						slidesPerView: 'auto',
						freeMode: true,
						// observer: true,
						// observeParents: true,
					});
				},

				// 初始化产品展示页swiper
				init_p2_swiper() {
					p2_swiper = new Swiper('.p2 .swiper-container', {
						direction: 'vertical',
						roundLengths: true,
						slidesPerView: 'auto',
						resistanceRatio: 0,
						freeMode: true,
						on: {
							slideChangeTransitionStart: () => {
								this.go_flag = true;
							},
						},
					});
				},

				// 初始化商家swiper信息
				init_p4_swiper() {
					p4_swiper = new Swiper('.p4 .swiper-container', {
						direction: 'vertical',
						roundLengths: true,
						slidesPerView: 'auto',
						freeMode: true,
						mousewheel: true,
						observer: true,
						observeParents: true,
					});
				},
			},
		})
	}



	//----------------------------------------页面监测代码----------------------------------------
	function monitor_handler() {
		imonitor.add({ obj: $('.p1 .rules'), action: 'touchstart', category: 'default', label: '活动规则' });
		imonitor.add({ obj: $('.p1 .down_icon'), action: 'touchstart', category: 'default', label: '下滑"宇"他告白' });
		imonitor.add({ obj: $('.p1 .send'), action: 'touchstart', category: 'default', label: '告白By U' });
		imonitor.add({ obj: $('.p1 .interaction_result .muen1'), action: 'touchstart', category: 'default', label: '邀请更多人告白By U' });
		imonitor.add({ obj: $('.p1 .interaction_result .muen2'), action: 'touchstart', category: 'default', label: '他的七夕至臻之选' });
		imonitor.add({ obj: $('.p2 .go'), action: 'touchstart', category: 'default', label: '即刻预购 By U告白甄选' });
		imonitor.add({ obj: $('.p.p3 .mask .empty_mask .btn'), action: 'touchstart', category: 'default', label: '已售罄 关闭' });
		imonitor.add({ obj: $('.p.p3 .p3_box .box_form .box_info .yuyue .yuyue_info.yuyue1'), action: 'touchstart', category: 'default', label: '专柜预约' });
		imonitor.add({ obj: $('.p.p3 .p3_box .box_form .box_info .yuyue .yuyue_info.yuyue2'), action: 'touchstart', category: 'default', label: '天猫预约' });
		imonitor.add({ obj: $('.p.p3 .p3_box .box_form .box_info .yuyue .yuyue_info.yuyue3'), action: 'touchstart', category: 'default', label: '京东预约' });
		imonitor.add({ obj: $('.p.p3 .mask .door_mask.door_mask door_mask1 .menu .menu2'), action: 'touchstart', category: 'default', label: '专柜预约  温馨提示 保留预约' });
		imonitor.add({ obj: $('.p.p3 .mask .door_mask.door_mask door_mask1 .menu .menu1'), action: 'touchstart', category: 'default', label: '专柜预约  温馨提示 更新预约' });

		imonitor.add({ obj: $('.p.p3 .mask .door_mask.door_mask door_mask2 .menu .menu2'), action: 'touchstart', category: 'default', label: '天猫预约  温馨提示 保留预约' });
		imonitor.add({ obj: $('.p.p3 .mask .door_mask.door_mask door_mask2 .menu .menu1'), action: 'touchstart', category: 'default', label: '天猫预约  温馨提示 更新预约' });


		imonitor.add({ obj: $('.p.p3 .mask .door_mask.door_mask door_mask3 .menu .menu2'), action: 'touchstart', category: 'default', label: '京东预约  温馨提示 保留预约' });
		imonitor.add({ obj: $('.p.p3 .mask .door_mask.door_mask door_mask3 .menu .menu1'), action: 'touchstart', category: 'default', label: '京东预约  温馨提示 更新预约' });
		imonitor.add({ obj: $('.p.p4 .p4_box .p4_main .submit'), action: 'touchstart', category: 'default', label: '确认提交' });
		imonitor.add({ obj: $('.p.p4 .p4_box .p4_main .yuyue .yuyue_info.yuyue2'), action: 'touchstart', category: 'default', label: '天猫预约' });
		imonitor.add({ obj: $('.p.p4 .p4_box .p4_main .yuyue .yuyue_info.yuyue3'), action: 'touchstart', category: 'default', label: '京东预约' });

		imonitor.add({ obj: $('.p.p5 .p5_box .share .tmail_info'), action: 'touchstart', category: 'default', label: '天猫Get更多白宇同款' });
		imonitor.add({ obj: $('.p.p5 .p5_box .share .jd_info'), action: 'touchstart', category: 'default', label: '京东Get更多白宇同款' });

		// imonitor.add({ obj: $('.p.p3 .mask .success_mask .btn'), action: 'touchstart', category: 'default', label: '天猫预约 预约成功 确认生成专属预约凭证' });

	}//end func
});//end ready
